package com.hailong.zyt.mapper;

import com.hailong.zyt.beans.Student;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author hailong
 * @since 2021-05-17
 */
public interface StudentMapper extends BaseMapper<Student> {

    /**
    * 根据作业id返回未完成改作业的学生
    * */
    @Select("select * from student where stu_id in " +
            "(select stu_id from course_all where cou_id in (select cou_id from homework hw where hw_id = #{hwId})) " +
            "and stu_id not in " +
            "(select stu_id from homework_student where hw_id = #{hwId}) ")
    List<Student> selectStudentsNotFinished(@Param("hwId") Long hwId);

    /**
     * 查询选了某门课的学生
     * */
    @Select("select * from student where stu_id in (select stu_id from course_all where cou_id = #{couId} and tea_id = #{teaId})")
    List<Student> selectStudentsByCouId(@Param("couId") Long couId, @Param("teaId") Long teaId);
}
